package com.the8thfold.anton.utils;

import java.security.SecureRandom;


public class QuickId {

    private static final SecureRandom sr = new SecureRandom();

    private static final char[] charChain = new char[]{
            'u','v','w','x','y','z',
            'F','G','H','I','J',
            '5','6','7','8','9',
            'a','b','c','d','e',
            'U','V','W','X','Y','Z',
            '5','6','7','8','9',
            'k','l','m','n','o',
            '0','1','2','3','4',
            'P','Q','R','S','T',
            '5','6','7','8','9',
            'f','g','h','i','j',
            '0','1','2','3','4',
            'A','B','C','D','E',
            '0','1','2','3','4',
            'K','L','M','N','O',
            '5','6','7','8','9',
            'p','q','r','s','t'
    };
    public static final int DEFAULT_LENGTH = 7;

    public static String getNewId(int length) {
        StringBuilder sb = new StringBuilder();
        for (int i=0; i < length; i++) {
            int r = sr.nextInt(charChain.length);
            sb.append(charChain[r]);
        }
        return sb.toString();
    }

    public static String getNewId() {
        return getNewId(DEFAULT_LENGTH);
    }
}
